package com.service.admin.order.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.service.admin.order.controller.rep.OrderProductLockComboRep;
import com.service.admin.order.controller.req.OrderProductLockComboReq;
import com.service.admin.order.service.OrderProductLockComboService;
import com.service.core.rest.response.CommonPageRep;
import com.service.dao.dto.rep.OrderProductLockComboPageRep;
import com.service.dao.mapper.OrderProductLockComboMapper;
import com.service.utility.modelmapper.ModelMapperUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 用户存币业务订单 接口实现
 *
 * @author 404notfound
 * @since 2021年05月12日18:24:47
 */
@Service
public class OrderProductLockComboServiceImpl implements OrderProductLockComboService {

    @Autowired
    private OrderProductLockComboMapper orderProductLockComboMapper;

    /**
     * 查询所有用户存币业务订单
     *
     * @param orderProductLockComboReq
     * @return
     */
    @Override
    public CommonPageRep<OrderProductLockComboRep> page(OrderProductLockComboReq orderProductLockComboReq) {
        Assert.notNull(orderProductLockComboReq, "参数[productLockComboPageReq]不能为null");
        //设置分页信息
        Page<OrderProductLockComboRep> page = PageHelper.startPage(orderProductLockComboReq.getPageNo(), orderProductLockComboReq.getPageSize());
        List<OrderProductLockComboPageRep> orderProductLockComboPageReps = orderProductLockComboMapper.list(orderProductLockComboReq.getLockNo(),orderProductLockComboReq.getUserAccount());
        List<OrderProductLockComboRep> req = orderProductLockComboPageReps.stream().map(item -> ModelMapperUtil
                .getStrictModelMapper().map(item, OrderProductLockComboRep.class)).collect(Collectors.toList());
        return CommonPageRep.buildResultRep(page, req);
    }
}
